home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kmditaskbar.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-09-10  |  6.7 KB  |  220 lines

  1. //----------------------------------------------------------------------------
  2. //    filename             : kmditaskbar.h
  3. //----------------------------------------------------------------------------
  4. //    Project              : KDE MDI extension
  5. //
  6. //    begin                : 07/1999       by Szymon Stefanek as part of kvirc
  7. //                                         (an IRC application)
  8. //    changes              : 09/1999       by Falk Brettschneider to create an
  9. //                           - 06/2000     stand-alone Qt extension set of
  10. //                                         classes and a Qt-based library
  11. //                           2000-2003     maintained by the KDevelop project
  12. //
  13. //    copyright            : (C) 1999-2003 by Falk Brettschneider
  14. //                                         and
  15. //                                         Szymon Stefanek (stefanek@tin.it)
  16. //    email                :  falkbr@kdevelop.org (Falk Brettschneider)
  17. //----------------------------------------------------------------------------
  18. //
  19. //----------------------------------------------------------------------------
  20. //
  21. //    This program is free software; you can redistribute it and/or modify
  22. //    it under the terms of the GNU Library General Public License as
  23. //    published by the Free Software Foundation; either version 2 of the
  24. //    License, or (at your option) any later version.
  25. //
  26. //----------------------------------------------------------------------------
  27.  
  28. #ifndef _KMDITASKBAR_H_
  29. #define _KMDITASKBAR_H_
  30.  
  31. #include <ktoolbar.h>
  32. #include <qptrlist.h>
  33. #include <qpixmap.h>
  34. #include <qlabel.h>
  35. #include <qpushbutton.h>
  36.  
  37. #include "kmdidefines.h"
  38.  
  39. class KMdiMainFrm;
  40. class KMdiChildView;
  41. class KMdiTaskBar;
  42.  
  43. class KMdiTaskBarButtonPrivate;
  44.  
  45. /**
  46.   * @short Internal class.
  47.   *
  48.   * It's a special kind of QPushButton catching mouse clicks.
  49.   * And you have the ability to abbreviate the text that it fits in the button.
  50.   */
  51. class KMDI_EXPORT KMdiTaskBarButton : public QPushButton
  52. {
  53.     Q_OBJECT
  54.     // methods
  55. public:
  56.     /**
  57.     * Constructor (sets to toggle button, adds a tooltip (caption) and sets to NoFocus
  58.     */
  59.     KMdiTaskBarButton( KMdiTaskBar *pTaskBar, KMdiChildView *win_ptr );
  60.     /**
  61.     * Destructor
  62.     */
  63.     ~KMdiTaskBarButton();
  64.     /**
  65.     * text() returns the possibly abbreviated text including the dots in it. But actualText() returns the full text.
  66.     */
  67.     QString actualText() const;
  68.     /**
  69.     * Given the parameter newWidth this function possibly abbreviates the parameter string and sets a new button text.
  70.     */
  71.     void fitText( const QString&, int newWidth );
  72.     /**
  73.     * Sets the text and avoids any abbreviation. Memorizes that text in m_actualText, too.
  74.     */
  75.     void setText( const QString& );
  76. signals:
  77.     /**
  78.     * Emitted when the button has been clicked. Internally connected to setFocus of the according MDI view.
  79.     */
  80.     void clicked( KMdiChildView* );
  81.     /**
  82.     * Internally connected with KMdiMainFrm::activateView
  83.     */
  84.     void leftMouseButtonClicked( KMdiChildView* );
  85.     /**
  86.     * Internally connected with KMdiMainFrm::taskbarButtonRightClicked
  87.     */
  88.     void rightMouseButtonClicked( KMdiChildView* );
  89.     /**
  90.     * Emitted when the button text has changed. Internally connected with KMdiTaskBar::layoutTaskBar
  91.     */
  92.     void buttonTextChanged( int );
  93. public slots:
  94.     /**
  95.     * A slot version of setText
  96.     */
  97.     void setNewText( const QString& );
  98. protected slots:
  99.     /**
  100.     * Reimplemented from its base class to catch right and left mouse button clicks
  101.     */
  102.     void mousePressEvent( QMouseEvent* );
  103.  
  104.     // attributes
  105. public:
  106.     /**
  107.     * The according MDI view
  108.     */
  109.     KMdiChildView *m_pWindow;
  110. protected:
  111.     /**
  112.     * Internally we must remember the real text because the button text can be abbreviated.
  113.     */
  114.     QString m_actualText;
  115.  
  116. private:
  117.     KMdiTaskBarButtonPrivate *d;
  118. };
  119.  
  120.  
  121. class KMdiTaskBarPrivate;
  122. /**
  123.  * @short Internal class.
  124.  *
  125.  * It's a special kind of QToolBar that acts as taskbar for child views.
  126.  * KMdiTaskBarButtons can be added or removed dynamically.<br>
  127.  * The button sizes are adjusted dynamically, as well.
  128.  */
  129. class KMDI_EXPORT KMdiTaskBar : public KToolBar
  130. {
  131.     Q_OBJECT
  132. public:
  133.     /**
  134.     * Constructor (NoFocus, minimum width = 1, an internal QPtrList of taskbar buttons (autodelete))
  135.     */
  136.     KMdiTaskBar( KMdiMainFrm *parent, QMainWindow::ToolBarDock dock );
  137.     /**
  138.     * Destructor (deletes the taskbar button list)
  139.     */
  140.     ~KMdiTaskBar();
  141.     /**
  142.     *Add a new KMdiTaskBarButton . The width doesn't change.
  143.     * If there's not enough space, all taskbar buttons will be resized to a new smaller size.
  144.     * Probably button texts must be abbreviated now.
  145.     */
  146.     KMdiTaskBarButton * addWinButton( KMdiChildView *win_ptr );
  147.     /**
  148.     * Removes a KMdiTaskBarButton and deletes it. If the rest of the buttons are smaller
  149.     * than they usually are, all those buttons will be resized in a way that the new free size is used as well.
  150.     */
  151.     void removeWinButton( KMdiChildView *win_ptr, bool haveToLayoutTaskBar = true );
  152.     /**
  153.     * Returns the neighbor taskbar button of the taskbar button of the MDI view given by parameter
  154.     * bRight specifies the side, of course left is used if bRight is false.
  155.     */
  156.     KMdiTaskBarButton * getNextWindowButton( bool bRight, KMdiChildView *win_ptr );
  157.     /**
  158.     * Get the button belonging to the MDI view given as parameter.
  159.     */
  160.     KMdiTaskBarButton * getButton( KMdiChildView *win_ptr );
  161.     /**
  162.     * Switch it on or off.
  163.     */
  164.     void switchOn( bool bOn );
  165.     /**
  166.     * @return whether switched on or off.
  167.     */
  168.     bool isSwitchedOn() const
  169.     {
  170.         return m_bSwitchedOn;
  171.     };
  172. protected:
  173.     /**
  174.     * Reimplemented from its base class to call layoutTaskBar, additionally.
  175.     */
  176.     void resizeEvent( QResizeEvent* );
  177. protected slots:
  178.     /**
  179.     * Checks if all buttons fits into this. If not, it recalculates all button widths
  180.     * in a way that all buttons fits into the taskbar and have got equal width.
  181.     * The text of the buttons will be abbreviated when nessecary, all buttons get a
  182.     * fixed width and show() is called for each one.
  183.     * If one drags the taskbar to a vertical orientation, the button width is set to 80 pixel.
  184.     */
  185.     void layoutTaskBar( int taskBarWidth = 0 );
  186. public slots:
  187.     /**
  188.     * Pushes the desired taskbar button down (switch on), the old one is released (switched off).
  189.     * Actually it's a radiobutton group behavior.
  190.     */
  191.     void setActiveButton( KMdiChildView *win_ptr );
  192. protected:
  193.     /**
  194.     * A list of taskbar buttons.
  195.     * Note: Each button stands for one MDI view (toolviews doesn't have got a taskbar button).
  196.     */
  197.     QPtrList<KMdiTaskBarButton>* m_pButtonList;
  198.     /**
  199.     * The belonging MDI mainframe (parent widget of this)
  200.     */
  201.     KMdiMainFrm* m_pFrm;
  202.     /**
  203.     * The MDI view belonging to the currently pressed taskbar button
  204.     */
  205.     KMdiChildView* m_pCurrentFocusedWindow;
  206.     /**
  207.     * A stretchable widget used as 'space' at the end of a half filled taskbar
  208.     */
  209.     QLabel* m_pStretchSpace;
  210.     bool m_layoutIsPending;
  211.     bool m_bSwitchedOn;
  212.  
  213. private:
  214.     KMdiTaskBarPrivate *d;
  215. };
  216.  
  217. #endif //_KMDITASKBAR_H_ 
  218. // kate: space-indent off; tab-width 4; replace-tabs off; indent-mode csands;
  219.  
  220.